package com.eastfair.certificate.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 制证订单
 * </p>
 *
 * @author ligang
 * @date 2023-07-07
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "CertificateOrderReturnTypeEnum", description = "退款方式:#{ONLINE:线上退款;OFFLINE:线下;-枚举")
public enum CertificateOrderReturnTypeEnum implements BaseEnum {

    /**
     * ONLINE="线上退款"
     */
    ONLINE("线上退款"),
    /**
     * OFFLINE="线下"
     */
    OFFLINE("线下"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static CertificateOrderReturnTypeEnum match(String val, CertificateOrderReturnTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static CertificateOrderReturnTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(CertificateOrderReturnTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "ONLINE,OFFLINE", example = "ONLINE")
    public String getCode() {
        return this.name();
    }

}
